/**
 * Created by chenshengli on 2015/6/19 0019.
 */



var addNewEnv = function () {
    var code = $('#envCode').val();
    var name = $('#envName').val();
    if (!code) {
        alert("环境编码为空！");
        return;
    }
    if (!name) {
        alert("环境名称为空！");
        return;
    }
    $.ajax({
        type: "PUT",
        url: "/manager/env",
        data: {code: code, name: name},
        cache: false,
        success: function (res) {
            if (res.status == "ok") {
                alert("环境添加成功！");
            } else {
                alert("环境添加失败！");
            }
            window.location.reload(true);
        },
        error: function () {
            alert("环境添加异常！");
            window.location.reload(true);
        }
    });
}


var deleteEnv = function (envId) {
    if (!window.confirm("是否要删除该环境？")) {
        return;
    }
    $.ajax({
        type: "DELETE",
        url: "/manager/env/" + envId,
        cache: false,
        success: function (res) {
            if (res.status == "ok") {
                alert("环境删除成功！");
            } else {
                alert("环境删除失败！");
            }
            window.location.reload(true);
        },
        error: function () {
            alert("环境删除异常！");
            window.location.reload(true);
        }
    });
}

var showHostParentSelect = function (obj) {
    $('.ui.modal').modal('show');
    $(obj).trigger("blur");
}

$('.menu .item').tab();
$('.ui.radio.checkbox').checkbox();